//
//  KYHeaderView.m
//  个人信息修改
//
//  Created by Yip-Jun on 16/5/4.
//  Copyright © 2016年 YIPWJ. All rights reserved.
//

#import "YZHeaderView.h"
#import "Masonry.h"

CGFloat widthOfIconViewWithHeaderView = 60;

@interface YZHeaderView ()

// 头像
@property (nonatomic, strong) UIImageView *iconView;
// 人头
@property (nonatomic, strong) UIImageView *personView;
// 笔
@property (nonatomic, strong) UIImageView *penView;
// 手机
@property (nonatomic, strong) UIImageView *phoneView;

// 名字
@property (nonatomic, strong) UILabel *nameLabel;
// 标识
@property (nonatomic, strong) UILabel *penLabel;
// 手机号码
@property (nonatomic, strong) UILabel *phoneLabel;

@end

@implementation YZHeaderView

+ (UIView *)headerView {
    
    YZHeaderView *hv = [[YZHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 120)];
    
    [hv prepareUI];
    return hv;
}

- (void)prepareUI {
    
    [self addSubview:self.iconView];
    [self addSubview:self.personView];
    [self addSubview:self.penView];
    [self addSubview:self.phoneView];
    
    [self addSubview:self.nameLabel];
    [self addSubview:self.penLabel];
    [self addSubview:self.phoneLabel];
    
    self.iconView.layer.cornerRadius = widthOfIconViewWithHeaderView * 0.5;
    self.iconView.layer.masksToBounds = YES;
    self.iconView.image = [UIImage imageNamed:@"name"];
    
    self.personView.image = [UIImage imageNamed:@"0"];
    self.penView.image = [UIImage imageNamed:@"idCard"];
    self.phoneView.image = [UIImage imageNamed:@"phone"];
}

- (void)layoutSubviews {
 
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.leading.equalTo(self).offset(32);
        make.width.height.mas_equalTo(widthOfIconViewWithHeaderView);
    }];
    
    [self.personView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.iconView.mas_trailing).offset(16);
        make.top.equalTo(self.iconView);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(14);
    }];
    
    [self.penView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.personView);
        make.centerY.equalTo(self.iconView);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(14);
    }];
    
    [self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.penView);
        make.bottom.equalTo(self.iconView);
        make.width.mas_equalTo(8);
        make.height.mas_equalTo(14);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.personView);
        make.leading.equalTo(self.personView.mas_trailing).offset(16);
    }];
    
    [self.penLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.nameLabel);
        make.centerY.equalTo(self.penView);
    }];
    
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.penLabel);
        make.centerY.equalTo(self.phoneView);
    }];
}


- (UIImageView *)iconView {
    if (!_iconView) {
        _iconView = [[UIImageView alloc] init];
    }
    return _iconView;
}

- (UIImageView *)personView {
    if (!_personView) {
        _personView = [[UIImageView alloc] init];
    }
    return _personView;
}

- (UIImageView *)penView {
    if (!_penView) {
        _penView = [[UIImageView alloc] init];
    }
    return _penView;
}

- (UIImageView *)phoneView {
    if (!_phoneView) {
        _phoneView = [[UIImageView alloc] init];
        [_phoneView sizeToFit];
    }
    return _phoneView;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.text = @"王云才";
        _nameLabel.font = [UIFont systemFontOfSize:13];
    }
    return _nameLabel;
}

- (UILabel *)penLabel {
    if (!_penLabel) {
        _penLabel = [[UILabel alloc] init];
        _penLabel.text = @"110109198707061355";
        _penLabel.font = [UIFont systemFontOfSize:13];
    }
    return _penLabel;
}

- (UILabel *)phoneLabel {
    if (!_phoneLabel) {
        _phoneLabel = [[UILabel alloc] init];
        _phoneLabel.text = @"13269130063";
        _phoneLabel.font = [UIFont systemFontOfSize:13];
    }
    return _phoneLabel;
}

@end
